package com.church.daoimpl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.church.dao.FriendsDao;
import com.church.db.Friends;

public class FriendsDaoImpl extends HibernateDaoSupport implements FriendsDao {
 

	@Override
	public String add(Friends friends) {
		this.getHibernateTemplate().save(friends);
		return "success";
	}

	@Override
	public String update(Friends friends) {
		this.getHibernateTemplate().update(friends);
		return "success";
	}

	@Override
	public Friends findById(int id) {
		 
		List<Friends> list=this.getHibernateTemplate().find("from Friends where id='"+id+"'");
		if(list.size()>0)
		{
			return list.get(0);
		}
		return null;
	}

	@Override
	public List<Friends> getList() {
		 
		return this.getHibernateTemplate().find("from Friends where state!='3'");
	}

}
